package com.share.config;

import org.springframework.context.annotation.*;
import org.springframework.orm.hibernate5.support.OpenSessionInViewFilter;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * author:caifan
 * date:2019/7/22
 */
@Configuration
@Import({DatabaseConfig.class})
@ComponentScan(basePackages = {"com.share.*"},
                excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)})
public class ConfigBean {

    @Bean
    public CharacterEncodingFilter characterEncodingFilter() {
        CharacterEncodingFilter filter = new CharacterEncodingFilter();
        filter.setEncoding("UTF-8");
        filter.setForceEncoding(true);
        return filter;
    }

    @Bean
    public OpenSessionInViewFilter openSessionInViewFilter() {
        OpenSessionInViewFilter openSessionInViewFilter = new OpenSessionInViewFilter();
        return openSessionInViewFilter;
    }

}
